import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:laos_mall/common/style/app_style.dart';
import 'package:laos_mall/common/style/extension_util.dart';
import 'package:laos_mall/common/utils/widget_util.dart';
import 'package:laos_mall/common/widght/dropdown/custom_dropdown.dart';
import 'package:laos_mall/pages/main/widgets/product_item.dart';
import 'package:laos_mall/pages/main/widgets/product_item_logic.dart';

import 'logic.dart';

class SearchProductPage extends StatelessWidget {
  SearchProductPage({Key? key}) : super(key: key);

  final logic = Get.put(SearchProductLogic());

  @override
  Widget build(BuildContext context) {
    return GetBuilder<SearchProductLogic>(builder: (logic) {
      return Scaffold(
      appBar: AppBar(),
      body: Column(children: [
        Row(children: [
          WidgetUtil.getSearchBar(key: logic.searchKey, onChanged: (value)=> logic.onchange(value), height: 40.h,autofocus: true,controller: logic.textEditingController,onEditingComplete: logic.onEditingComplete).addExpand(),
          AppButton.sizeBtn(logic.goSearch, width: 49.w,
              "GO".tr,
              style: AppButtonStyle.textPrimary)
        ],).addContainer(height: 40.h, padding: EdgeInsets.only(left: 20.w)),

        PositionedDropdown(
          key: logic.dropDownKey,
          items: logic.searchResult,
          type: PositionedDropdownType.search,
          onItemSelected: ( index) {
            logic.search(index as int);
          },
          width: ScreenUtil().screenWidth, // 自定义宽度
        ),
        ProductItemWidget(name: 'search',title: "may_like".tr,para: logic.searchPara,).addExpand()
      ],),
      );
    });
  }

  _openDropDown() {

  }

}


